package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingLevel;
import com.zzyl.entity.NursingPlan;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NurLeUpdateVo;
import com.zzyl.vo.NursingLevelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingLevelServiceImpl implements NursingLevelService {
    @Autowired
    private NursingLevelMapper nursingLevelMapper;
    @Override
    public List<NursingLevelVo> listAll() {
        List<NursingLevelVo> list = nursingLevelMapper.listAll();
        return list;
    }

    @Override
    public void addLevel(NursingLevel nursingLevel) {
        // nursingLevel.setCreateBy();
        nursingLevelMapper.addLevel(nursingLevel);
    }

    @Override
    public PageResponse<NursingLevelVo> listPage(String name, Integer pageNum, Integer pageSize, Integer status) {
        PageResponse<NursingLevelVo> pageResponse = new PageResponse<>();
        PageHelper.startPage(pageNum, pageSize);
        Page<NursingLevelVo> page = nursingLevelMapper.list(name, status);
        pageResponse.setRecords(page);
        pageResponse.setTotal(page.getTotal());
        pageResponse.setPages((long) page.getPages());
        pageResponse.setPage(page.getPageNum());
        return pageResponse;
    }

    @Override
    public NursingLevelVo getById(Long id) {
        NursingLevelVo nursingLevelVo = nursingLevelMapper.getById(id);
        return nursingLevelVo;}


    @Override
    public void disableById(Long id, Integer status) {
        nursingLevelMapper.disableById(id,status);
    }


    @Override
    public void deleteById(Long id) {

        nursingLevelMapper.deleteById(id);
    }

    @Override
    public void updateById(NurLeUpdateVo nursingLevel) {

        nursingLevelMapper.updateNL(nursingLevel);
    }
}
